﻿// JSON C# Class Generator
// http://at-my-window.blogspot.com/?page=json-class-generator

using System;
using Newtonsoft.Json.Linq;
using Sina.Altman.Weibo.SDK.Objects;
using System.Linq;

namespace Sina.Altman.Weibo.SDK.Objects
{
    /// <summary>
    /// 信息流,包含微博详情
    /// </summary>
    public class Status 
	{

		public Status(string json)
		 : this(JObject.Parse(json))
		{
		}

		private JObject __jobject;
		public Status(JObject obj)
		{
			this.__jobject = obj;
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private Status2[] _statuses;
		public Status2[] Statuses
		{
			get
			{
				if(_statuses == null)
					_statuses = (Status2[])JsonClassHelper.ReadArray<Status2>(JsonClassHelper.GetJToken<JArray>(__jobject, "statuses"), JsonClassHelper.ReadStronglyTypedObject<Status2>, typeof(Status2[]));
				return _statuses;
			}
            set
            {
                _statuses = value;
            }
		}

		public int PreviousCursor
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "previous_cursor"));
			}
		}

		public long NextCursor
		{
			get
			{
				return JsonClassHelper.ReadLong(JsonClassHelper.GetJToken<JValue>(__jobject, "next_cursor"));
			}
		}

		public int TotalNumber
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "total_number"));
			}
		}
	}
	
    /// <summary>
    /// 用户信息
    /// </summary>
	public class User
	{
        public User(string json)
            : this(JObject.Parse(json))
        {
        }


		private JObject __jobject;
		public User(JObject obj)
		{
			this.__jobject = obj;
		}

		public int Id
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "id"));
			}
		}

		public string ScreenName
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "screen_name"));
			}
		}

		public string Name
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "name"));
			}
		}

		public string Province
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "province"));
			}
		}

		public string City
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "city"));
			}
		}

		public string Location
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "location"));
			}
		}

		public string Description
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "description"));
			}
		}

		public string Url
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "url"));
			}
		}

		public string ProfileImageUrl
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "profile_image_url"));
			}
		}

		public string Domain
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "domain"));
			}
		}

		public string Gender
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "gender"));
			}
		}

		public int FollowersCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "followers_count"));
			}
		}

		public int FriendsCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "friends_count"));
			}
		}

		public int StatusesCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "statuses_count"));
			}
		}

		public int FavouritesCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "favourites_count"));
			}
		}

		public string CreatedAt
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "created_at"));
			}
		}

		public bool Following
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "following"));
			}
		}

		public bool AllowAllActMsg
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "allow_all_act_msg"));
			}
		}

		public string Remark
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "remark"));
			}
		}

		public bool GeoEnabled
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "geo_enabled"));
			}
		}

		public bool Verified
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "verified"));
			}
		}

		public bool AllowAllComment
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "allow_all_comment"));
			}
		}

		public string AvatarLarge
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "avatar_large"));
			}
		}

		public string VerifiedReason
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "verified_reason"));
			}
		}

		public bool FollowMe
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "follow_me"));
			}
		}

		public int OnlineStatus
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "online_status"));
			}
		}

		public int BiFollowersCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "bi_followers_count"));
			}
		}

	}

    /// <summary>
    /// 围脖详情
    /// </summary>
	public class Status2
	{
        public Status2(string json):this(JObject.Parse(json))
        {

        }

		private JObject __jobject;
		public Status2(JObject obj)
		{
			this.__jobject = obj;
		}

		public string CreatedAt
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "created_at"));
			}
		}

		public long Id
		{
			get
			{
				return JsonClassHelper.ReadLong(JsonClassHelper.GetJToken<JValue>(__jobject, "id"));
			}
		}

		public string Text
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "text"));
			}
		}

		public string Source
		{
			get
			{
                var sources = JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "source")).Split('>');
                return sources[sources.Length-2].Split('<').FirstOrDefault();
			}
		}

		public bool Favorited
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "favorited"));
			}
		}

		public bool Truncated
		{
			get
			{
				return JsonClassHelper.ReadBoolean(JsonClassHelper.GetJToken<JValue>(__jobject, "truncated"));
			}
		}

		public string InReplyToStatusId
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "in_reply_to_status_id"));
			}
		}

		public string InReplyToUserId
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "in_reply_to_user_id"));
			}
		}

		public string InReplyToScreenName
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "in_reply_to_screen_name"));
			}
		}

		public object Geo
		{
			get
			{
				return JsonClassHelper.ReadObject(JsonClassHelper.GetJToken<JToken>(__jobject, "geo"));
			}
		}

		public string Mid
		{
			get
			{
				return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "mid"));
			}
		}

		public int RepostsCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "reposts_count"));
			}
		}

		public int CommentsCount
		{
			get
			{
				return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "comments_count"));
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private object[] _annotations;
		public object[] Annotations
		{
			get
			{
				if (_annotations == null)
					_annotations = (object[])JsonClassHelper.ReadArray<object>(JsonClassHelper.GetJToken<JArray>(__jobject, "annotations"), JsonClassHelper.ReadObject, typeof(object[]));
				return _annotations;
			}
		}

		[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
		private User _user;
		public User User
		{
			get
			{
				if (_user == null)
					_user = JsonClassHelper.ReadStronglyTypedObject<User>(JsonClassHelper.GetJToken<JObject>(__jobject, "user"));
				return _user;
			}
		}

	}
}
